function isCandidateUserIsCustomAuth(candidateUserConfig = {}) {
    if (!candidateUserConfig) {
        return false
    }
    if (!candidateUserConfig.confKey) {
        return false;
    }
    return "custom_auth_candidate" === candidateUserConfig.confKey

}

function taskIsCustomAuth(procTasks = [], taskDefKey = '') {
    if (!procTasks || procTasks.length < 1) {
        return false;
    }
    let index = 0;
    if (taskDefKey) {
        index = procTasks.findIndex(e => e.taskDefKey === taskDefKey)
    }
    if (index < 0) {
        return false;
    }
    let task = procTasks[index];
    if (!task.taskConfig || !task.taskConfig.act_task_candidate_user) {
        return false
    }
    return task.taskConfig.act_task_candidate_user.confKey === 'custom_auth_candidate'
}

function procNextTaskIsCustomAuth(procTasks = []) {
    if (!procTasks || procTasks.length < 1) return null;
    let index = procTasks.findIndex(e => e.handlerState === 10)
    if (index < 0) {
        return null;
    }
    index = index + 1
    if (!(index < procTasks.length)) {
        return null;
    }
    let task = procTasks[index]
    if (!isCandidateUserIsCustomAuth(task.candidateUserConfig)) {
        return null;
    }
    return procTasks[index]
}


const startActTools = {
    taskIsCustomAuth,
    procNextTaskIsCustomAuth
}
export default startActTools
